package movee.domain.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 *
 *
 * @author movee
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AppException extends RuntimeException {

    private AppStatusCode statusCode;
    private Object detail;

    public AppException(AppStatusCode statusCode, final String msg) {
        super(msg);
        this.statusCode = statusCode;
        this.detail = null;
    }

    public AppException(AppStatusCode statusCode, final String msg, Throwable t) {
        super(msg, t);
        this.statusCode = statusCode;
        this.detail = null;
    }

    public AppException(AppStatusCode statusCode, final String msg, Throwable t, Object detail) {
        super(msg, t);
        this.statusCode = statusCode;
        this.detail = detail;
    }

    /**
     * 这个方法只是为了消代码检查告警
     * @return apiStatusCode
     */
    public AppStatusCode getApiStatusCode() {
        return statusCode;
    }

    public Object getDetail() {
        return detail;
    }

    public AppException setDetail(Object detail) {
        this.detail = detail;
        return this;
    }
}
